package com.atguigu.eduservice;

import com.atguigu.eduservice.entity.EduSubject;
import com.atguigu.eduservice.service.EduSubjectService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;
import java.util.stream.Collectors;


@SpringBootTest
@RunWith(SpringRunner.class)
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;

    @Test
    public void getAllSubject(){
        List<EduSubject> list = eduSubjectService.list();
        list.stream().filter(eduSubject -> eduSubject.getParentId().equals("0")).forEach(eduSubject -> {
            System.out.println("一级分类的课程:"+eduSubject);
        });
        list.stream().filter(eduSubject -> !eduSubject.getParentId().equals("0")).forEach(eduSubject -> {
            System.out.println("二级分类的课程:"+eduSubject);
        });

    }

}
